'use strict';
const rd = require("../module/redis.js");
/** http提示信息 */
exports.run = function(req, res){
    const fun = require("../module/base");
    switch(req.GET.query.ac){ 
        case "paysuccess":{//支付成功提示
            let m = require("./shop");
            m.run({ json: [4,66,req.GET.query] }, null); //uid:用户id，pid:道具id，pn:支付金额
            break;
        }case "reload":{//重新加载脚本
            let BP = __dirname.substr(0, __dirname.length - 4);
            if (require.cache[BP + req.GET.query.p]) {
                var md = require(BP + req.GET.query.p);
                if (md.destroy) {
                    md.destroy();
                }
                delete require.cache[BP + req.GET.query.p];
                LOG.error(req.GET.query.p + ' cache is delete');
                require(BP + req.GET.query.p);
            }else{
                LOG.error(BP + req.GET.query.p + ' not cache');
            }
            break;
        }case "closeaccount":{//封停账号
            rd().HGET("UserOnLine", req.GET.query.uid, function(err, rep){
                if(err) return;
                if(rep && rep != 0){ //玩家在线 踢下线
                    var sdata = {index:rep,serverid:31,userid:req.GET.query.uid,channelid:0};
                    fun.writeData(CLIENT, sdata, [6,255,{"T":1000,"C":216}]);
                    fun.writeData(CLIENT, sdata, null);
                }
            });
            break;
        }case "color":{ //生成关卡内容
            const gamecolor = require("./gamecolor");
            res.end(gamecolor.randChapter(req.GET.query.S, req.GET.query.N));
            return;
        }default:{
            HLOG.error("not find", req.GET.query.ac);
        }
    }
    res.end('1');
};